﻿/*
 * XDevelopHelper
 *  @Author: XTST
 *  @Git: https://gitee.com/XTST/XUnityDevelopHelper
 *  Copyright © 2013-2018 Xiaotian Jin. All rights reserved.
 * */

using System;
using XDevelopHelper.Event.Base;

namespace XDevelopHelper.Event
{
    internal sealed class EventManager : BaseModule, IEventManager
    {
        #region Data

        EventPool<BaseEventArgs> eventPool;

        #endregion

        #region Constructor

        public EventManager()
        {
            eventPool = new EventPool<BaseEventArgs>();
        }

        #endregion

        #region Event Manager

        public bool Check(int id, EventHandler<BaseEventArgs> handlerToCheck)
        {
            return eventPool.Check(id, handlerToCheck);
        }

        public void Subscribe(int id, EventHandler<BaseEventArgs> handler)
        {
            eventPool.Subscribe(id, handler);
        }

        public void Unsubscribe(int id, EventHandler<BaseEventArgs> handler)
        {
            eventPool.Unsubscribe(id, handler);
        }

        public void Fire(object sender, BaseEventArgs e)
        {
            eventPool.Fire(sender, e);
        }

        #endregion

        #region Updater

        internal override void Update(float elapseSeconds, float realElapseSeconds)
        {
            eventPool.Update();
        }

        #endregion
    }
}
